
var g_page = 1;//页码
var g_next = true;//是否有下页

//获取靓号列表
function get_list(input_type,input_areaid,input_num)
{
	var ab = 0;

	$.getJSON("ajax/get_list.php",{type:1,area:input_areaid,page:g_page,num:input_num},
	function (json){
		if(json.err == "1")
		{
			Uconfirm(json.errinfo);
			return false;
		}
		else
		{
			if(json.list.length == 0)
			{
				g_next = false;
				$("#phone_list p").eq(0).nextAll().remove();//清空表格
				return false;
			}
			if(json.list.length < 5)
			{
				g_next = false;
			}
			else
			{
				g_next = true;
			}
			$("#phone_list p").eq(0).nextAll().remove();//清空表格
			for(var i in json.list)
			{
				var str = "";
				str += "<div class='button_yuan button_margin' onclick=choose_phone("+json.list[i].phone_code+",'"+json.list[i].area_id+"')>";
				if(json.list[i].phone_fee == 0)json.list[i].phone_fee = 100;
				//str += "<span class='fontcol div_margin'>"+json.list[i].phone_code+"</span>";
				if(0 == 1)
				{
					str += "<span class='fontcol div_margin'>"+get_c_code(json.list[i].phone_code,input_num)+"</span>";
				}
				else
				{
					str += "<span class='fontcol div_margin'>"+json.list[i].phone_code+"</span>";
				}
				//if(0 == 0)
				//{
				str += "<span class='fontcol div_margin'>预存话费"+json.list[i].phone_fee+"元</span><a class='fontcol div_margin'>"+json.list[i].area_name+"</a>";
				//}
				str += "</div>";
				$("#phone_list").append(str);
			}
		}
	});
}

//获取上一页列表
function goto_pre()
{
	if(g_page > 1)
	{
		g_page = g_page - 1;
		g_next = true;
		//get_list();
	}
}
//获取下一页列表
function goto_next()
{
	if(g_next)
	{
		g_page = g_page + 1;
		//get_list();
	}
}
//选择靓号跳转
function choose_phone(phone_code,area)
{
	//联通订单同步接口
	$.getJSON("ajax/checkMobile.php",{uid:1,phone_code:phone_code},
	function (json){
		if(json.err == "1")
		{
			Uconfirm(json.errinfo);
			return false;
		}
		else
		{
			location.href='info1.php?uid=1&domain=.&appkey=dm&phone_code='+phone_code+'&type=0&uuid='+json.uuid+'&mobileId='+json.mobileId+'&area='+area;
			//location.href='info1.php?uid=1&phone_code='+phone_code+'&type='+0;
		}
	});
	//location.href='info1.php?uid=1&phone_code='+phone_code+'&type=0&area='+area;
}

var _index = -1;
//check_show1("showshow"+_index);

//改变号码颜色
function get_c_code(code,num)
{
	if(num.indexOf("}") > 0 )
	{
		var arr=num.split("}{");
		arr[0] = arr[0].substr(1,1);
		var ostr = "";
		for(var j in arr)
		{
			ostr += parseInt(arr[j]);
		}
	}
	else
	{
		var ostr = num;
	}
	var str = "";
	//str = code.replace(ostr,"<span style='color:red;'>"+ostr+"</span>");
	//Uconfirm(code);
	var arr2=code.split(ostr);
	str = arr2[0];
	for(var i = 1;i<arr2.length;i++)
	{
		//Uconfirm(arr2[i]);
		str += "<span style='color:red;'>"+ostr+"</span>"+arr2[i];
	}
	/*if(arr2[1] != undefined)
	{
	str += arr2[1];
	}*/

	return str;
}
